﻿using JGSY.CourseManagement.Infrastructure.Data.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JGSY.CourseManagement.Infrastructure.Services
{
    // 创建一个非静态的数据库迁移服务
    // 在 Infrastructure 层创建一个非静态类用于日志记录
    /// <summary>
    /// 注册数据库迁移辅助类
    /// </summary>
    public class DatabaseMigrator
    {
        private readonly ILogger<DatabaseMigrator> _logger;

        public DatabaseMigrator(ILogger<DatabaseMigrator> logger)
        {
            _logger = logger;
        }

        public void LogMigrationError(Exception ex)
        {
            _logger.LogCritical(ex, "数据库迁移失败");
        }
    }
}
